import mongoose from 'mongoose';

const Schema = mongoose.Schema;
const ObjectId = Schema.Types.ObjectId;
const QuestionScoreSchema = new Schema({
    schoolId: {
        type: ObjectId,
        ref: 'School'
    },
    gradeId: {
        type: ObjectId,
        ref: 'Grade'
    },
    classId: {
        type: ObjectId,
        ref: 'Clazz'
    },
    className: String,
    examId: {
        type: ObjectId,
        ref: 'Exam'
    },
    examGroupId: {
        type: ObjectId,
        ref: 'ExamGroup'
    },
    prevExamId: {
        type: ObjectId,
        ref: 'Exam'
    },
    //上次相同考试组的id
    prevExamGroupId: {
        type: ObjectId,
        ref: 'ExamGroup'
    },
    type: Number,//1理科，2文科，3艺体, 4通用
    subjectId: {
        type: ObjectId,
        ref: 'Subject'
    },
    questionId: {
        type: ObjectId,
        ref: 'Question'
    },
    // 题号
    questionNumber: Number,
    subjectName: String,
    type: Number,//类型
    answer: String,//选择题答案
    studentAnswer: String,//学生的答案
    studentId: {
        type: ObjectId,
        ref: 'Student'
    },
    studentName: String,
    // 得分
    score: Number,
    // 此题总分数
    totalScore: Number,
});
QuestionScoreSchema.pre('save', function (next) {
    this.createdAt = new Date();
    next();
});

let quesScoreModel = mongoose.model('QuesScore', QuestionScoreSchema);

export default quesScoreModel;